package com.zimin.shared.pojo;

import com.zimin.shared.enums.ResponseStatusEnum;

/**
 * 公共的Controller
 *
 * @author zimin
 * @since 2021/10/18 11:32 上午
 */
public class BaseController {

    /**
     * 封装返回对象
     *
     * @param obj 校验参数
     * @return
     */
    public Result result(Object obj) {
        if (obj == null) {
            return Result.error();
        }

        if (obj instanceof Boolean) {
            return (boolean) obj ? Result.ok() : Result.error();
        }
        return Result.ok(obj);
    }

    public Result result(Object obj, ResponseStatusEnum responseStatusEnum) {
        if (obj == null) {
            return Result.error();
        }

        if (obj instanceof Boolean) {
            return (boolean) obj ? Result.ok() : Result.error();
        }
        return Result.ok(responseStatusEnum,obj);
    }


}
